/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package byblos.negocio.pacote;

import byblos.util.DataUtil;
import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;

/**
 *
 * @author Diego
 */
@Entity
@NamedQueries(value = {@NamedQuery(name = "PacoteAbertoPorIdioma", query = "SELECT p FROM PacoteAberto p WHERE p.idioma = ?1 AND p.removido = false"),
    @NamedQuery(name = "PacoteAbertoPorIdiomaHome", query = "SELECT p FROM PacoteAberto p WHERE p.visivelHome = true AND p.idioma = ?1 AND p.removido = false"),
    @NamedQuery(name = "PacoteAbertoPorPeriodo", query = "SELECT p FROM PacoteAberto p WHERE p.removido = false AND " +
    "?1 >= p.dataInicio AND ?1 < p.dataTermino OR " +
    "?2 > p.dataInicio AND ?2 <= p.dataTermino OR " +
    "?1 < p.dataInicio AND ?2 > p.dataTermino")
})
public class PacoteAberto extends Pacote<ItemPacoteAbertoCategoria> implements Serializable {

    @Temporal(javax.persistence.TemporalType.DATE)
    private Calendar dataInicio;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Calendar dataTermino;
    private int numeroNoites;

    public PacoteAberto() {
        super(TipoPacote.ABERTO);
    }

    @Override
    public Calendar getInicio() {
        return getDataInicio();
    }

    @Override
    public Calendar getTermino() {
        return getDataTermino();
    }

    public int getNumeroNoites() {
        return numeroNoites;
    }

    public void setNumeroNoites(int numeroNoites) {
        this.numeroNoites = numeroNoites;
    }

    public Calendar getDataInicio() {
        return dataInicio;
    }

    public String getStringDataInicio() {
        return DataUtil.toString(dataInicio);
    }

    public void setDataInicio(Calendar dataInicio) {
        this.dataInicio = dataInicio;
    }

    public Calendar getDataTermino() {
        return dataTermino;
    }

    public String getStringDataTermino() {
        return DataUtil.toString(dataTermino);
    }

    public void setDataTermino(Calendar dataTermino) {
        this.dataTermino = dataTermino;
    }
}
